/**
 * Created by hsiacool on 2017/8/25.
 */
import e = require('express');
import BaseController from "./BaseController";
import { router } from "../decorators/Web";
import {ArticleDetailDao} from "../dao/index";
import {ArticleDao} from "../dao/index";

class DetailController extends BaseController {


    @router({
        method: 'get',
        path: '/detail.html'
    })
    async index(req: any, res: e.Response) {
        ArticleDao.find({ciId:req.query.ciId}).then((articleciId:any)=>{
            let caId = JSON.parse(articleciId[0].content)[0].data[0].ca_id;
            console.log(caId);
            ArticleDetailDao.find({caId:caId}).then((articledetail:any)=>{
            super.render(req,res,'/detail.html',{data:{data1:articleciId,data2:articledetail}});
            });
        });
    }
}

export default DetailController
